local duojing = fk.CreateSkill {

  name = "joy_mou__duojing",

  tags = {  },

}



duojing:addEffect("active", {
  name = "joy_mou__duojing",
  anim_type = "control",
  card_num = 0,
  min_target_num = 1,
  max_target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(duojing.name, Player.HistoryPhase) < 2 
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
      return to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local to = effect.tos[1]
    local choices = U.doStrategy(room, player, to, {"joy__duojing-xiuyang","joy__duojing-baiyi"}, {"joy__duojing-xiuyang2","joy__duojing-baiyi2"}, duojing.name, 1)
    local win = true
    if choices[1] == "joy__duojing-xiuyang" and choices[2] ~= "joy__duojing-xiuyang2" then
      player:broadcastSkillInvoke("joy_mou__shilve", 2)
      if not to:isNude() then
        room:doIndicate(player.id, {to.id})
        local card = room:askForCardChosen(player, to, "he", duojing.name)
        room:obtainCard(player, card, false, fk.ReasonPrey)
      end
      if not player.dead then
        player.room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = duojing.name
          })
      end
      local n = player.maxHp - player.hp
      if not player.dead and n > 0 and room:askForSkillInvoke(player,duojing.name,".","#joy_mou__duojing-zhiheng:::"..n) then
        player:drawCards(n,duojing.name)
        if not player.dead then
          room:askForDiscard(player,n,n)
        end
      end
    elseif choices[1] == "joy__duojing-baiyi" and choices[2] ~= "joy__duojing-baiyi2" then
      room:addPlayerMark(to, fk.MarkArmorNullified)
      room:useVirtualCard("slash", nil, player, to, duojing.name,true)
      room:removePlayerMark(to, fk.MarkArmorNullified)
      room:addPlayerMark(player, MarkEnum.SlashResidue.."-turn")
      room:setPlayerMark(player,"joy__keji-turn",1)
    end
  end,
})

return duojing